//
//  ViewController.m
//  第三题
//
//  Created by dllo on 16/6/3.
//  Copyright © 2016年 dllo. All rights reserved.-
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    [self addView];
    
}

-(void)addView
{
    CGFloat weidth = self.view.frame.size.width / 5;
    CGFloat height = self.view.frame.size.height / 8;
    for (int i = 1; i <= 8; i++) {
        for (int j = 1; j <= 5; j++) {
            int R = arc4random() % 256;
            int G = arc4random() % 256;
            int B = arc4random() % 256;
            UIView *view = [[UIView alloc]initWithFrame:CGRectMake(weidth * (j - 1), height * (i - 1), weidth , height)];
            view.backgroundColor = [UIColor colorWithRed:R/255.0  green:G/255.0  blue:B/255.0  alpha:1];
            [self.view addSubview:view];
            [view release];
        }
    }

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
